package projeto1;

import java.awt.BorderLayout;
import java.awt.FlowLayout;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;

import java.awt.Font;

import javax.swing.JTextField;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.Color;
import javax.swing.ImageIcon;


public class LoginAdm extends JDialog {
	private JTextField tfusuario;
	private JTextField tfsenha;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		try {
			LoginAdm dialog = new LoginAdm();
			dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
			dialog.setVisible(true);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * Create the dialog.
	 */
	public LoginAdm() {
		setBounds(100, 100, 450, 300);
		getContentPane().setLayout(null);
		{
			JLabel lblNewLabel = new JLabel("\u00C1rea restrita. Insira seus dados para continuar:");
			lblNewLabel.setForeground(Color.BLACK);
			lblNewLabel.setFont(new Font("Arial", Font.BOLD, 15));
			lblNewLabel.setBounds(65, 11, 339, 18);
			getContentPane().add(lblNewLabel);
		}
		{
			JLabel lblLogin = new JLabel("Login");
			lblLogin.setForeground(Color.BLACK);
			lblLogin.setFont(new Font("Arial", Font.PLAIN, 15));
			lblLogin.setBounds(17, 70, 35, 18);
			getContentPane().add(lblLogin);
		}
		{
			tfusuario = new JTextField();
			tfusuario.setBounds(66, 70, 302, 20);
			getContentPane().add(tfusuario);
			tfusuario.setColumns(10);
			
		}
		{
			JLabel lblSenha = new JLabel("Senha");
			lblSenha.setFont(new Font("Arial", Font.PLAIN, 15));
			lblSenha.setBounds(17, 113, 42, 18);
			getContentPane().add(lblSenha);
		}
		{
			tfsenha = new JTextField();
			tfsenha.setBounds(66, 113, 302, 20);
			getContentPane().add(tfsenha);
			tfsenha.setColumns(10);
			
		}
		{
			JButton btnOk = new JButton("Ok");
			btnOk.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					String usuario = tfusuario.getText().toString();
					String senha = tfsenha.getText().toString();
					BDLogin bd = new BDLogin();
					bd.BDLogar(usuario, senha);
					if(bd.valida){
						Cadastro cad = new Cadastro();
						cad.setVisible(true);
					}
					else{
						JOptionPane.showMessageDialog(null, "ERRO");
//						ErroLogin erro = new ErroLogin();				
					}
					bd.valida=false;
					
				}
			});
			btnOk.setFont(new Font("Arial", Font.PLAIN, 15));
			btnOk.setBounds(186, 224, 51, 27);
			getContentPane().add(btnOk);
		}
		{
			JLabel lblNewLabel_1 = new JLabel("");
			lblNewLabel_1.setIcon(new ImageIcon("C:\\Users\\vania\\Desktop\\customLogo.gif.jpg"));
			lblNewLabel_1.setBounds(10, 125, 441, 126);
			getContentPane().add(lblNewLabel_1);
		}
	}

}

